package com.luzhikun.HVJdemol.db;

import java.sql.*;

/**
 * @Author Rookie Coder
 * @Description JDBC工具类
 * @Date
 **/
public class JDBCUtil {

    static {
        try {
            Class.forName("com.mysql.jdbc.Driver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }

    public Connection getConnection() throws SQLException {
        Connection connection=null;
        String url="jdbc:mysql://localhost:3306/mvcsystem";
        String password="140489lu";
        String root="root";
        if (connection==null)
        connection= DriverManager.getConnection(url,root,password);
        return connection;
    }
    public void closeAll(Connection connection, PreparedStatement pst, ResultSet rs) throws SQLException {
        if (connection!=null){
            connection.close();
        }
        if (pst!=null){
            pst.close();
        }
        if (rs!=null){
            rs.close();
        }
    }


}
